import 'package:flutter/material.dart';
import 'package:flutter_demo/ui/pages/status/data/share_data_notifier.dart';
import 'package:flutter_demo/ui/pages/status/inherited/notifier/a1_page_widget.dart';
import 'package:flutter_demo/ui/pages/status/inherited/notifier/b1_page_widget.dart';
import 'package:flutter_demo/ui/pages/status/inherited/notifier/share_notifier_widget.dart';

/*
 * 和 update方案类似， 
 * 只是添加了 Notifier 支持共享数据必须继承 ChangeNotifier ，
 * 实现数据变更通知。
 */
class InheritedNotifierTestWidget extends StatefulWidget {
  InheritedNotifierTestWidget({super.key});
  ShareDataNotifier shareData = ShareDataNotifier(nickname: "初始值", level: 11);

  @override
  State<InheritedNotifierTestWidget> createState() =>
      _InheritedNotifierTestState();
}

class _InheritedNotifierTestState extends State<InheritedNotifierTestWidget> {
  @override
  Widget build(BuildContext context) {
    return ShareNotifierWidget(
      shareData: widget.shareData,
      //child: MaterialApp(home: APage()),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [A1PageWidget(), B1PageWidget()],
      ),
    );
  }
}
